<?php
require_once 'PHPUnit/Framework.php';

require_once dirname(__FILE__).'\poklon.php';

/**
 * Description of PoklonTest
 *
 * @author Bojan
 */
class PoklonTest extends PHPUnit_Framework_TestCase {
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp() {
        $this->object = new Poklon("Jabuka", 20);
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown() {
    }

    public function testOcenjivanjePlus() {
        $trenPluseva = $this->object->dohvatiPluseve();
        $this->object->dodajPlus();
        $noviPlusevi = $this->object->dohvatiPluseve();
        $this->assertEquals(1, $noviPlusevi - $trenPluseva, "Broj pluseva nije uvecan za 1");
    }

    public function testOcenjivanjeMinus() {
        $trenMinusa = $this->object->dohvatiMinuse();
        $this->object->dodajMinus();
        $noviMinusi = $this->object->dohvatiMinuse();
        $this->assertEquals(1, $noviMinusi - $trenMinusa, "Broj minusa nije uvecan za 1");
    }

    public function testOcena() {
        $trenOcena = $this->object->dohvatiOcenu();
        $this->object->dodajPlus();
        $this->object->dodajMinus();
        $novaOcena = $this->object->dohvatiOcenu();
        $this->assertEquals($trenOcena, $novaOcena, "Ocena se ne izracunava pravilno");
    }

    public function testNaziv() {
        $tempNaziv = $this->object->dohvatiNaziv();
        $this->object->promeniNaziv("NekiNaziv");
        $noviNaziv = $this->object->dohvatiNaziv();

        $this->assertEquals("NekiNaziv", $noviNaziv, "Naziv se ne menja pravilno");

        $this->object->promeniNaziv($tempNaziv);
    }

    public function testCena() {
        $tempCena = $this->object->dohvatiCenu();
        $this->object->promeniCenu("NekiCena");
        $noviCena = $this->object->dohvatiCenu();

        $this->assertEquals("NekiCena", $noviCena, "Cena se ne menja pravilno");

        $this->object->promeniCenu($tempCena);
    }
}
?>
